% Class for Variable in Model
% Properties:
%   1. Name
%   2. Dimension
%   3. State or Control
%   4. Linearized or LogLinearized
%   5. Steady State Value
% Methods:
%   1. Dev2Level
classdef DsgeVarClass < handle
    properties
        Name
        Dim
        Type
        LinLog
        SS
    end
    methods
        % Generate the Combined Function Approximation Structure
        function VAR=DsgeVarClass(Name,StSt,Type,LinLog)
            VAR.Name    =   Name;
            if ~isvector(StSt)
                error('Please input a vector or scalar');
            end
            VAR.Dim     =   length(StSt(:));
            VAR.SS      =   StSt;
            if ~strcmp(Type,'State_Ex') && ~strcmp(Type,'State_En') && ~strcmp(Type,'Control')
                error('Variable type has to be State_Ex, State_En or Control');
            end
            VAR.Type    =   Type;
            if ~strcmp(LinLog,'Lin') && ~strcmp(LinLog,'Log')
                error('Variable deviation type has to be Lin or Log');
            end
            VAR.LinLog  =   LinLog;
        end
        function Level=Dev2Level(obj,Dev)
            switch obj.LinLog
                case 'Lin'
                    Level   =   obj.SS+Dev;
                case 'Log'
                    Level   =   obj.SS .* exp(Dev);
            end
        end
        function Dev=Level2Dev(obj,Level)
            switch obj.LinLog
                case 'Lin'
                    Dev     =   Level-obj.SS;
                case 'Log'
                    Dev     =   log(Level./obj.SS);
            end
        end
    end
end